package com.itheima.mArrayList;

import java.util.ArrayList;
import java.util.Scanner;

/*
     键盘录入
 */
public class ArrayListDemo04 {
    public static void main(String[] args) {
        ArrayList<Student> students = new ArrayList<>();
        //引导输入
        while (true) {
            Scanner sc = new Scanner(System.in);
            System.out.println("姓名:(输入-1以结束)");
            String name = sc.next();
            if (name.equals("-1")) {
                break;
            }
            System.out.println("年龄:");
            int age = sc.nextInt();
            Student s = new Student(name, age);
            students.add(s);
        }
        for (int i = 0; i < students.size(); i++) {
            Student s1 = students.get(i);
            System.out.println("姓名:" + s1.getName());
            System.out.println("年龄:" + s1.getAge());
        }
        //删除
        ArrayList<String> s = new ArrayList<>();
        s.add("111 ");
        s.add("111 ");
        s.add("111 ");
        s.add("111 ");
        s.add("111 ");
        s.add("112 ");
        s.add("111 ");
        s.add("112 ");
        s.add("111 ");
        s.add("112 ");
        while (true){
            int j = s.size();
            s.remove("112 ");
            if(s.size()<j){
                continue;
            }else{
                break;
            }
        }
        System.out.println(s);
    }
}
